home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
shufl1
/
sound1.frm
< prev
next >
Wrap
Text File
|
1995-05-08
|
11KB
|
359 lines
VERSION 2.00
Begin Form Sound1
Caption = "System Sound Shuffler"
ClientHeight = 3870
ClientLeft = 1185
ClientTop = 1545
ClientWidth = 7890
Height = 4275
Icon = SOUND1.FRX:0000
Left = 1125
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 3870
ScaleWidth = 7890
Top = 1200
Width = 8010
Begin CommonDialog CMDialog1
Left = 5400
Top = 4320
End
Begin CommandButton Command1
Caption = "E&xit"
Height = 375
Index = 5
Left = 6300
TabIndex = 14
Top = 3120
Width = 1335
End
Begin CommandButton Command1
Caption = "Shu&ffle"
Height = 375
Index = 4
Left = 6300
TabIndex = 13
Top = 2580
Width = 1335
End
Begin CommandButton Command1
Caption = "&Set Current"
Height = 375
Index = 3
Left = 6300
TabIndex = 12
Top = 2040
Width = 1335
End
Begin CommandButton Command1
Caption = "&Play File"
Height = 375
Index = 2
Left = 6300
TabIndex = 11
Top = 1500
Width = 1335
End
Begin CommandButton Command1
Caption = "&Remove File"
Height = 375
Index = 1
Left = 6300
TabIndex = 10
Top = 960
Width = 1335
End
Begin CommandButton Command1
Caption = "&Add File"
Height = 375
Index = 0
Left = 6300
TabIndex = 9
Top = 420
Width = 1335
End
Begin PictureBox Picture3
BackColor = &H00C0C0C0&
BorderStyle = 0 'None
Height = 3195
Left = 240
ScaleHeight = 3195
ScaleWidth = 5775
TabIndex = 0
Top = 360
Width = 5775
Begin CheckBox chEnabled
BackColor = &H00C0C0C0&
Caption = "Shuffling E&nabled"
Height = 255
Left = 240
TabIndex = 6
Top = 2760
Width = 2775
End
Begin ListBox lbFiles
Height = 1395
Left = 1020
TabIndex = 4
Top = 1140
Width = 4455
End
Begin ComboBox coEvents
Height = 300
Left = 1020
Style = 2 'Dropdown List
TabIndex = 2
Top = 240
Width = 3315
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "Shuffle &Files:"
Height = 435
Index = 1
Left = 240
TabIndex = 3
Top = 1140
Width = 735
End
Begin Label laSound
BackColor = &H00C0C0C0&
Height = 255
Left = 1620
TabIndex = 8
Top = 720
Width = 3975
End
Begin Label Label2
BackColor = &H00C0C0C0&
Caption = "Current Sound:"
Height = 255
Left = 240
TabIndex = 7
Top = 720
Width = 1335
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "&Event:"
Height = 255
Index = 0
Left = 240
TabIndex = 1
Top = 300
Width = 615
End
End
Begin PictureBox Picture1
BorderStyle = 0 'None
Height = 255
Left = 0
Picture = SOUND1.FRX:0302
ScaleHeight = 255
ScaleWidth = 375
TabIndex = 5
Top = 0
Visible = 0 'False
Width = 375
End
End
Dim NewFlag As Integer
Sub chEnabled_Click ()
If NewFlag Then Exit Sub
x% = chEnabled.Value
Key$ = coEvents.Text
Res% = WritePrivateProfileString("Enabled", Key$, Str$(x%), "Shuffle.ini")
End Sub
Sub coEvents_Click ()
UpdateFiles
PassedString$ = Space$(gSize)
Key$ = coEvents.Text
a% = GetPrivateProfileString("Enabled", Key$, "", PassedString$, gSize, "Shuffle.ini")
temp$ = Left$(PassedString$, a%)
NewFlag = True
If temp$ = "1" Then
chEnabled.Value = 1
Else
chEnabled.Value = 0
End If
NewFlag = False
End Sub
Sub Command1_Click (Index As Integer)
Select Case Index
Case 0 'Add File
CMDialog1.DefaultExt = "WAV"
CMDialog1.DialogTitle = "Select Sound File"
CMDialog1.FileName = ""
CMDialog1.Filter = "Sound (*.wav)|*.wav"
CMDialog1.FilterIndex = 1
CMDialog1.Flags = OFN_FILEMUSTEXIST Or OFN_NOCHANGEDIR
If gsInitDir <> "" Then CMDialog1.InitDir = gsInitDir
CMDialog1.Action = 1
FName$ = CMDialog1.FileName
FTitle$ = CMDialog1.FileTitle
If FName$ <> "" Then
gsInitDir = Left$(FName$, Len(FName$) - Len(FTitle$) - 1)
If Len(gsInitDir) < 3 Then gsInitDir = gsInitDir + "\"
IniApp$ = coEvents.Text
x% = InStr(FTitle$, ".")
If x% <> 0 Then
Key$ = Mid$(FTitle$, 1, x% - 1)
Else
Key$ = FTitle$
End If
a% = WritePrivateProfileString(IniApp$, Key$, FName$, "Shuffle.ini")
UpdateFiles
End If
Case 1 'Remove a file
If lbFiles.ListIndex = -1 Then
Msg$ = "Select a sound file to remove"
MsgType% = MB_ICONASTERISK
Title$ = "System Sound Shuffler"
sMsgBox Msg$, MsgType%, Title$
Exit Sub
End If
FName$ = lbFiles.Text
Msg$ = "Are you sure you want to remove " + FName$ + "?"
Title$ = "System Sound Shuffler"
Res% = fMsgBox(Msg$, MB_ICONQUESTION + 3, Title$)
If Res% = 6 Then
LastNdx% = 1
NextNdx% = 1
Cut% = 0
While NextNdx% <> 0
NextNdx% = InStr(LastNdx%, FName$, "\")
If NextNdx% <> 0 Then
Cut% = NextNdx%
End If
LastNdx% = NextNdx% + 1
Wend
If Cut% <> 0 Then
FName$ = Mid$(FName$, Cut% + 1)
End If
x% = InStr(FName$, ".")
If x% Then FName$ = Left$(FName$, x% - 1)
IniApp$ = coEvents.Text
Res% = KillIniKey(IniApp$, FName$, 0&, "Shuffle.ini")
UpdateFiles
End If
Case 2 'Play selected file
If lbFiles.ListIndex = -1 Then
Msg$ = "Select a sound file to play"
sMsgBox Msg$, MB_ICONASTERISK, "System Sound Shuffler"
Exit Sub
End If
FName$ = lbFiles.Text
Sound1.MousePointer = 11
sndPlaySound FName$, 2
Sound1.MousePointer = 0
Case 3 'Set Current
MakeFileCurrent
Case 4 'Randomize
MousePointer = 11
Msg1.Show 0
Junk% = DoEvents()
Shuffle
WinKey$ = gEventsArray(coEvents.ListIndex, 1)
PassedString$ = Space$(gSize)
a% = GetProfileString("Sounds", WinKey$, "[None]", PassedString$, gSize)
x% = InStr(PassedString$, ",")
If x% Then
CurrentSound$ = Left$(PassedString$, x% - 1)
Else
CurrentSound$ = Left$(PassedString$, a%)
End If
laSound.Caption = CurrentSound$
Unload Msg1
MousePointer = 0
Case 5 'Done
End
End Select
End Sub
Sub Form_Load ()
Screen.MousePointer = 11
WindowState = 0